package com.kantboot.tool.area.web.controller;

import com.kantboot.tool.area.repository.ToolAdAreaRepository;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tool-area-web/toolAdArea")
public class ToolAdAreaController {

    @Resource
    private ToolAdAreaRepository repository;

    @RequestMapping("/getByStateAreaCodeAndParentAdCode")
    private RestResult<?> getByStateAreaCodeAndParentAdCode(
            @RequestParam("stateAreaCode") String stateAreaCode,
            @RequestParam("parentAdCode") String parentAdCode) {
        if (parentAdCode == null || parentAdCode.isEmpty()) {
            return RestResult.success(repository.getByStateAreaCode(stateAreaCode),"getSuccess","获取成功");
        }
        return RestResult.success(repository.getByStateAreaCodeAndParentAdCode(stateAreaCode, parentAdCode),"getSuccess","获取成功");
    }
}
